package greedy.总结.基础;

public class leetcode392判断子序列 {
    public boolean isSubsequence(String s, String t) {
        int sIndex = 0;
        int tIndex = 0;
        int sLength = s.length();
        int tLength = t.length();
        if (sLength == 0) {
            return true;
        }
        while (sIndex < sLength && tIndex < tLength) {
            if (s.charAt(sIndex) == t.charAt(tIndex)) {
                sIndex++;
            }
            tIndex++;
            if (sIndex == sLength) {
                return true;
            }
        }
        return false;
    }
}
